package com.hubstc.book_borrow.mapper;

import com.hubstc.book_borrow.pojo.Category;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BookCategoryMapper {

    //添加类别
    @Insert("insert into type (categoryName,total) values (#{categoryName},#{total});")
    void addCategory(Category category);

    //查询所有类别
    @Select("select * from type")
    List<Category> findAllCategory();
    
    //根据类别id查询类别
    @Select("select * from type where categoryId=#{categoryId}")
    Category findCategoryById(int categoryId);
    
    //更新类别信息
    @Update("update type set categoryName = #{categoryName},total=#{total} where categoryId=#{categoryId};")
    void updateCategory(Category category);

    //删除图书分类
    @Delete("delete from type where categoryId=#{categoryId}")
    void deleteCategory(int categoryId);
}
